package com.sinotopia.domain;

import org.hibernate.annotations.Type;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.*;

@Table(name = "category")
@Entity
public class Category {

    private Integer id;
    private String categoryName;

    private Integer createdByUser;

    private Date creationTime;

    private Integer modifiedByUser;

    private Date modifyActionTime;

//    private Set<Item> items = new HashSet<Item>();

    @GeneratedValue
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "category_name")
    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

//    @ManyToMany(mappedBy = "categories")
//    public Set<Item> getItems() {
//        return items;
//    }

//    public void setItems(Set<Item> items) {
//        this.items = items;
//    }

    @Column(name = "create_user_id", nullable = false)
//    @CreatedBy
    public Integer getCreatedByUser() {
        return createdByUser;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_datetime", nullable = false)
    @CreatedDate
    public Date getCreationTime() {
        return creationTime;
    }

    public void setCreatedByUser(Integer createdByUser) {
        this.createdByUser = createdByUser;
    }

    public void setCreationTime(Date creationTime) {
        this.creationTime = creationTime;
    }


    @Column(name = "last_modified_user_id", nullable = false)
    @LastModifiedBy
    public Integer getModifiedByUser() {
        return modifiedByUser;
    }

    public void setModifiedByUser(Integer modifiedByUser) {
        this.modifiedByUser = modifiedByUser;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_modified_datetime")
    @LastModifiedDate
    public Date getModifyActionTime() {
        return modifyActionTime;
    }

    public void setModifyActionTime(Date modifyActionTime) {
        this.modifyActionTime = modifyActionTime;
    }
}